package com.example.myapplication.tack_13.adapter;

import android.app.Activity;
import android.content.Context;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.Toolbar;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.myapplication.R;
import com.example.myapplication.tack_13.DetailsActivity;
import com.example.myapplication.tack_13.OutpatientActivity;
import com.example.myapplication.tack_13.data.ArrageData;
import com.example.myapplication.tack_13.data.DeparArragneData;
import com.example.myapplication.utils.Common;
import com.example.myapplication.utils.OkHttpTool;

import java.util.List;

public class DepartmentAdapter extends RecyclerView.Adapter<DepartmentAdapter.My> {
    private List<DeparArragneData.RowsDTO> list;
    private Context context;
    private View view;

    public DepartmentAdapter(List<DeparArragneData.RowsDTO> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @NonNull
    @Override
    public My onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        view = LayoutInflater.from(context).inflate(R.layout.tack_13_deparment_list,null);
        return new My(view);
    }

    @Override
    public void onBindViewHolder(@NonNull My holder, int position) {
        holder.categoryName.setText(list.get(position).getCategoryName());
        holder.money.setText("价格："+list.get(position).getMoney()+" ￥");

        holder.lien.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(context,"预约成功",Toast.LENGTH_SHORT).show();
                ((Activity) context).finish();
            }
        });
    }

    @Override
    public int getItemCount() {
        return list != null?list.size():0;
    }

    public class My extends RecyclerView.ViewHolder{
        private TextView categoryName;
        private TextView money;

        private LinearLayout lien;
        public My(@NonNull View itemView) {
            super(itemView);
            categoryName = view.findViewById(R.id.categoryName);
            money = view.findViewById(R.id.money);
            lien = view.findViewById(R.id.lien);
        }
    }
}
